package com.boge.study.design_pattern.singlecase;

/**
 * 懒汉式
 * 为了保证线程安全，使用了双重检查锁定的方式
 * 
 * ~ Java中Volatile关键字详解 http://www.cnblogs.com/zhengbin/p/5654805.html
 * @author Administrator
 *
 */
public class LazytonSecurity {

	private LazytonSecurity() {}
	
	public static volatile LazytonSecurity instance = null;
	
	public static LazytonSecurity getInstance() {
		if (instance == null) {
			synchronized (LazytonSecurity.class) {
				if (instance == null) {
					instance = new LazytonSecurity();
				}
			}
		}
		return instance;
	}
	
}
